#include "EditorInstance.hpp"

/** 
* Create new editor instance for the map.
* @param m Map being edited.
*/
EditorInstance::EditorInstance(Map* m){
    map = m;
    cameraPosition = new EditorEntity(map->width*16, map->height*16);
    if(((int)cameraPosition->x)%32 != 0) cameraPosition->x += 16;
    if(((int)cameraPosition->y)%32 != 0) cameraPosition->y += 16;
    selectedTool = EditorInstance::Brush;
    moveSource.left = moveSource.top = moveSource.width = moveSource.height = 0;
    marqueeTool.left = marqueeTool.top = marqueeTool.width = marqueeTool.height = 0;
}

EditorInstance::~EditorInstance(){
    delete map;
    map = 0;
    for(int i = 0; i < actionHistory.size(); i++){
        delete actionHistory.at(i);
    }
    for(int i = 0; i < redoHistory.size(); i++){
        delete redoHistory.at(i);
    }
}